package com.itheima.manager;

import com.itheima.common.R;
import com.itheima.domain.OmsOrderReturnReason;
import com.itheima.service.OmsOrderReturnReasonService;
import com.itheima.vo.PageBeanVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class OmsOrderReturnReasonManager {

    @DubboReference
    OmsOrderReturnReasonService omsOrderReturnReasonService;

    //退货原因表分页查询
    public R findByPage(int pageNum, int pageSize) {
        PageBeanVo vo= omsOrderReturnReasonService.findByPage(pageNum,pageSize);
        return R.success(vo);
    }

    //回显数据
    public OmsOrderReturnReason getInfoById(Long id) {
        return omsOrderReturnReasonService.findInfoById(id);
    }

    //修改退货原因
    public void updateById(OmsOrderReturnReason reason) {
        omsOrderReturnReasonService.updateReturnReason(reason);
    }

    //修改退货原因状态
    public void updateStatus(Integer ids, Integer status) {
        OmsOrderReturnReason reason = new OmsOrderReturnReason();
        reason.setId(Long.valueOf(ids));
        reason.setStatus(status);
        omsOrderReturnReasonService.updateReturnReason(reason);
    }

    //批量删除退货原因
    public void delete(List<Long> ids) {
        omsOrderReturnReasonService.deleteByIds(ids);
    }

    //添加退货原因
    public void save(OmsOrderReturnReason omsOrderReturnReason) {
        omsOrderReturnReasonService.save(omsOrderReturnReason);
    }
}
